<?php
/**
 * Created by PhpStorm.
 * User: 王松
 * Time: 2017/7/6 12:43
 */

namespace App\Project\Printer;

use App\Models\MarriageHistory;
use App\Models\Patient;

class MarriagePrinter extends PrinterAbstract
{
    protected $patient;

    public function __construct(MarriageHistory $person, Patient $patient)
    {
        $this->model = $person;
        $this->patient = $patient;
    }

    public function marriage()
    {
        if (!$this->model->marriage) {
            return '';
        }

        $print = [
            $this->fe('marriage', 'time', '患者于', '结婚'),
            $this->fe('marriage', 'son', '育有', '子'),
            $this->fe('marriage', 'daughter', '', '女'),
        ];

        if ($this->patient->female()) {
            if ($this->model->macrosomia&&$this->model->macrosomia['key']) {
                $print[] = '有生产巨大儿';
            } else {
                $print[] = '没有生产巨大儿';
            }
        }

        return $this->getPrintStr('', $print);
    }

    public function menstruation()
    {
        if ($this->patient->male()) {
            return '';
        }

        //  月经初潮年龄为14岁，经期8天，不规律；周期8天，规律；月经量一般；在10岁已停经；
        $menstruation = $this->model->menstruation;

        if (!$menstruation) {
            return '';
        }

        $print = [
            $this->fe('menstruation', 'menarche', '月经初潮年龄为', '岁'),
        ];

        if (isset($menstruation['period']['days']) && !empty($menstruation['period']['days'])) {
            $print[] = $this->fe('menstruation', 'period.days', '经期', '天');
            $print[] = $menstruation['period']['law']['value'];
        }

        if (isset($menstruation['cycle']['days']) && !empty($menstruation['cycle']['days'])) {
            $print[] = $this->fe('menstruation', 'cycle.days', '周期', '天');
            $print[] = $menstruation['cycle']['law']['value'];
        }

        $print[] = $this->ft(
            'marriage.menstruation.menstrual_volume',
            $menstruation['menstrual_volume'],
            '月经量'
        );

        $print[] = $this->fe('menstruation', 'last_time.date', '末次月经：');
        $print[] = $this->fe('menstruation', 'last_time.continue', '持续时间 ');
        $print[] = $this->fe('menopause', 'age', '在', '岁已停经');

        return $this->getPrintStr('', $print);
    }
}